﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RushTracker.Core.Util
{
    public static class KeyGenerator
    {
        private const string CHARACTERS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";

        public static string Generate()
        {
            return Generate(30);
        }

        public static string Generate(int length)
        {
            StringBuilder sb = new StringBuilder();
            Random rand = new Random(DateTime.UtcNow.Millisecond);

            for (int i = 0; i < length; i++)
            {
                int pos = rand.Next(0, CHARACTERS.Length);
                sb.Append(CHARACTERS[pos]);
            }

            return sb.ToString();
        }
    }
}
